
import 'package:flutter/material.dart';
import 'package:flutterdemo01/demo56/Login.dart';
import 'package:flutterdemo01/demo56/main.dart';
import 'package:flutterdemo01/demo56/register1.dart';
import 'package:flutterdemo01/demo56/register2.dart';
import 'package:flutterdemo01/demo56/register3.dart';

final routesInfo = {
  "/": (context) => MainPage(),
  "/login": (context) => Login(),
  "/register1": (context, {arguments}) => Register1(
        arguments: arguments,
      ),
  "/register2": (context, {arguments}) => Register2(
        arguments: arguments,
      ),
  "/register3": (context, {arguments}) => Register3(
        arguments: arguments,
      ),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // print('object');
  String? name = settings.name;
  final Function pageContentBuilder = routesInfo[name] as Function;
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
